package thread;

/**
 * @Author: zhanghuan
 * @date: 2020/10/2 14:09
 * @description:
 */
public class TestStop implements  Runnable {

    //1。设置一个标志位
    private boolean falg = true;
    @Override
    public void run() {
        while (falg) {
            System.out.println(Thread.currentThread().getName());
        }
    }
    //2.设置一个公开的方法，停止线程
    public void stop() {
        this.falg = false;
    }

    public static void main(String[] args) {

    }
}
